﻿@model IEnumerable<MvcMusicStore.Album>
@if (ViewBag.result == false)
{
    <h2>
        Enter the search string!</h2>
}
else
{
    if (Model.Count() == 0)
    {
    <h2>
        Albums were not found!</h2>
    }
    else
    {
    <div id="search">
        <h3>
            <em>Albums</em></h3>
        <ul id="album-list">
            @foreach (var album in Model)
            {
                <li><a href="@Url.Action("Details", "Store", new { id = album.id })">
                    <img alt="@album.titleAlbum" src="@album.coverAlbum" />
                    <p>@album.titleAlbum</p>
                    <span><em>Genre:</em>@album.Genre.nameGenre</span> <span><em>Artist:</em>@album.Author.nameAuthor</span>
                    <span><em>Price:</em>@String.Format("{0:F}", album.coustAlbum)</span> </a>

                @if(album.aspnet_Users.Any(a => a.UserName == User.Identity.Name))
                {
                    <strong class="button">Already bought</strong>
                }
                else
                {
                    <p class="button">
                        @Html.ActionLink("Buy it now!", "PurchaseAlbum", "Cart", new { id = album.id }, "")
                    </p>
                }

                    
                </li>
            }
        </ul>
    </div>
    }
}
